// Package service /*linux+go
package service

import (
	"strings"

	cf "godocker/common/functions"
)

type linuxGo struct {
	SName string

	basicDir []string
	version  string
}

func linuxGoNew() *linuxGo {
	return &linuxGo{
		"linux-go",
		[]string{
			installDir + "/worker/golang/src",
			installDir + "/worker/golang/bin",
			installDir + "/worker/golang/pkg",
		},
		cf.GetEnvVal(installDir+"/.env", "gov="),
	}
}

func (lg *linuxGo) install() {
	lg.mkdir()

	lg.setDockerFile()
}

func (lg *linuxGo) mkdir() {
	for _, v := range lg.basicDir {
		cf.MakeDir(v)
	}
}

func (lg *linuxGo) setDockerFile() {
	str := cf.GetDockerfile("Dockerfile-golang")

	newStr := strings.Replace(str, "{$version}", lg.version, -1)

	cf.WriteToFileTrunc(ymlDir+"/Dockerfile-golang", newStr)
}
